package pub.zhouhui.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import pub.zhouhui.services.Monitor.MonitorController;
import pub.zhouhui.services.Monitor.MonitorFunction;

/**
 * Created by shane on 16-11-16.
 */
@RestController
public class ThreadTest {
    @Autowired
    MonitorFunction monitorFunction;
    @Autowired
    MonitorController monitorController;
    @ApiOperation(value = "", notes = "")
    @ApiImplicitParam(name = "name", value = "name", required = true, dataType = "String")
    @RequestMapping(value = "/start/{name}", method = RequestMethod.POST)
    public String startMonitor(@PathVariable String name) {
        monitorController.setMontitorHashMap(name, true);
        monitorFunction.createNewThread(name);
        return "success";
    }

    @ApiOperation(value = "", notes = "")
    @ApiImplicitParam(name = "name", value = "name", required = true, dataType = "String")
    @RequestMapping(value = "/stop/{name}", method = RequestMethod.POST)
    public String stopMonitor(@PathVariable String name) {
        monitorController.setMontitorHashMap(name, false);
        return "success";
    }


}
